package com.fr.report.highlight;

import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.report.CellElement;
import com.fr.report.Report;
import com.fr.report.script.Calculator;

public class RowHeightHighlightAction extends AbstractHighlightAction
{
  private int rowHeight;

  public RowHeightHighlightAction()
  {
  }

  public RowHeightHighlightAction(int paramInt)
  {
    this.rowHeight = paramInt;
  }

  public int getRowHeight()
  {
    return this.rowHeight;
  }

  public void setRowHeight(int paramInt)
  {
    this.rowHeight = paramInt;
  }

  public void action(CellElement paramCellElement, Calculator paramCalculator)
  {
    if ((paramCellElement == null) || (paramCalculator == null))
      return;
    Report localReport = paramCalculator.getCurrentReport();
    if (localReport == null)
      return;
    int i = paramCellElement.getRow();
    int j = i + paramCellElement.getRowSpan();
    while (i < j)
    {
      localReport.setRowHeight(i, this.rowHeight);
      ++i;
    }
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if ((paramXMLableReader.isChildNode()) && ("RowHeight".equals(paramXMLableReader.getTagName())))
    {
      String str;
      if ((str = paramXMLableReader.getAttr("i")) != null)
        setRowHeight(Integer.parseInt(str));
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    if (this.rowHeight > 0)
      paramXMLPrintWriter.startTAG("RowHeight").attr("i", this.rowHeight).end();
  }
}